package com.practice.xml.jaxb;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import com.practice.xml.Employee;
import com.practice.xml.EmployeeDefinition;

@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = EmployeeDefinition.NAME, propOrder = { "name", "sex", "age" })
class JaxbEmployee {

	@XmlElement(name = EmployeeDefinition.ELEMENT_NAME)
	private String name;

	@XmlElement(name = EmployeeDefinition.ELEMENT_SEX)
	private boolean sex;

	@XmlElement(name = EmployeeDefinition.ELEMENT_AGE)
	private int age;

	public JaxbEmployee() {
	}

	public JaxbEmployee(Employee employee) {
		this.name = employee.getName();
		this.sex = employee.getSex();
		this.age = employee.getAge();
	}

	public Employee toEmployee() {
		Employee employee = new Employee();
		employee.setName(this.name);
		employee.setSex(this.sex);
		employee.setAge(this.age);
		return employee;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean getSex() {
		return sex;
	}

	public void setSex(boolean sex) {
		this.sex = sex;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

}
